<div class="uploadWrapper${fieldname}">
	<input type="button" class="button" value="上传" id="uploadBtn_${fieldname}" style="float: left" />
	<input type="hidden" name="${fieldname}" id="${fieldname}" value="${value!''}" />
	<div style="width: 150px; height: 150px; overflow: hidden; float: left">
		<img id="img_${fieldname}" style="width: 150px; height: 150px;"	<#if !value?? || value==""> src="${ctx}/cms/admin/images/transparent.gif"  <#else> src="${value}" </#if> />
	</div>
	<div style="display: none; float: left; margin: 130px 0 0 5px;"	id="divdelbtn_${fieldname}">
		<a href="javascript:;" id="delBtn_${fieldname}" title="删除此图片">
			<img class="delete" src="${ctx}/cms/admin/images/transparent.gif" />
		</a>
	</div>
</div>
<script type="text/javascript">
	$(function(){
			
		$("#uploadBtn_${fieldname}").click(function(){
			$("#photoDiv").dialog({
				title : "上传图片",
				top : 130,
				width : 500,
				height : 200,
				closed : false,
				cache : false,
				href : "${ctx}/eop/upload/file.do?subFolder=spec",
				modal : true,
				buttons : [ {
					text : '保存',
					handler : function() {
						var path="";
						var options ={
								url:"${ctx}/eop/upload/upload-file.do?ajax=1",
								dataType:"json",
								success:function(data){
									if(data.result == 1){
										${fieldname}getPath(data.path);
									}else{
										alert(data.message);
									}
								},
								error:function(){
									alert("上传错误，请重试");
								}
							};
							$('#uploadForm').ajaxSubmit(options);
						$("#photoDiv").dialog('close');
					}
				}]
			});
		});
		
		$("#delBtn_${fieldname}").click(function(){
			$("#img_${fieldname}").attr("src","images/transparent.gif");
			$("#${fieldname}").val("");
		});
		
	})
function ${fieldname}getPath(path){    
	$("#img_${fieldname}").attr("src",path);
	$("#${fieldname}").val(path);
}
</script>


